package servlets;

import interfaces.IFachada;

import java.io.Console;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import modelos.Aluno;
import modelos.Endereco;
import fachada.Fachada;

@WebServlet("/EditaAluno")
public class EditaAluno extends HttpServlet {
	private static final long serialVersionUID = 1L;

	private IFachada fachada = new Fachada();

	private int id;

	public EditaAluno() {
	}

	protected void service(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {

		this.id = Integer.parseInt(request.getParameter("id"));
		PrintWriter out = response.getWriter();

		try {
			request.setAttribute("aluno", fachada.getAlunoPorId(id));
			RequestDispatcher d = request.getRequestDispatcher("pages/Aluno/EditaAluno.jsp");
			d.forward(request, response);
		} catch (Exception e) {
			response.sendRedirect("pages/Aluno/erro.jsp");
		}
	}

}
